from pyquery import PyQuery
from fake_useragent import *
import requests

# pyquery的使用

url = "https://www.kuaidaili.com/free/"
headers = {
    "User-agent": UserAgent().chrome
}
response = requests.get(url, headers=headers)
# response.encoding = "gbk"
doc = PyQuery(response.text)
trs = doc("tr")
for num in range(1, len(trs)):
    ip = trs.eq(num).find("td").eq(0).text()
    port = trs.eq(num).find("td").eq(1).text()
    type = trs.eq(num).find("td").eq(3).text()
# doc("tr").eq(2).find("td").eq(0).text()
# ips = doc("")
# ports = doc("")
# types = doc("")
    print(f"{ip}:{port}   {type}")
